file = open("broken-scores.txt", encoding='utf-8')

scores = []

for line in file:
    strings = line[0:len(line)-1].split(',')
    for s in strings:
        if len(s) == 0:
            continue
        try:
            scores.append(int(s))
        except:
            print('"{}" is not a valid number.'.format(s))

print(scores)

print('Their average is {}.'.format(sum(scores)/len(scores)))
